import java.net.ConnectException;
import java.util.Random;

/**
 * Created with Intellij IDEA.
 * Description;
 * User:墨琦
 * Data:2023-04-09
 * Time:10:18
 */
public class Text {
    public  static MyList.List Connect(MyList.List one,MyList.List two)
    {
        MyList.List<Integer> kk=new MyList.List<>(-1);
        MyList.List<Integer> cur=kk;
        kk.next=null;
        while(two!=null&&one!=null)
        {
            if((int)two.data>(int)one.data)
            {
                cur.next=one;
                cur=cur.next;
                one=one.next;
            }
            else{
                cur.next=two;
                cur=cur.next;
               two=two.next;
            }
        }
        if(two!=null)
        {
            cur.next=two;
        }
        if(one!=null)
        {
            cur.next=one;
        }
        return kk.next;
    }
    public static void main(String[] args) {
        MyList<Integer> one=new MyList<Integer>();
        for(int i=0;i<5;i++)
        {
           /* Random fw=new Random();
            one.insertHead(fw.nextInt(50));*/
            one.insertTail(i+3);
        }
        one.show(); System.out.println();
      /*

        one.reversal();
        one.show();*/
        MyList<Integer> two=new MyList<Integer>();
        for(int i=0;i<5;i++)
        {
            /*Random fw=new Random();
            two.insertHead(fw.nextInt(50));*/
            two.insertTail(i+4);
        }
        two.show(); System.out.println();
        MyList.List<Integer> ret= Connect(one.head,two.head);
            one.show(ret);
    }


}
